<?php 
header('Content-type:text/html;charset=utf-8');
if ($_POST){
	$num1 = $_POST['num1'];
	$num2 = $_POST['num2'];
	$a = floatval($num1);
	$b = floatval($num2);
	if($num1=='0' || $num1==''){
		$a=1;
		$num1='0';
	} 
	if($num2=='0' || $num2==''){
		$b=1;
		$num2='0';
	} 
	$a1=strval($a);
	$b1=strval($b);
	var_dump($num1,$num2,$a,$b,$a1,$b1);
	$yunsuan = $_POST['yunsuan'];
	if(strlen($num1)==strlen($a1)&&strlen($num2)==strlen($b1)){
		if($a&&$b){
			switch ($yunsuan) {
				case '+':
					$re = $num1 + $num2;
					break;
				case '-':
					$re = $num1 - $num2;
					break;
				case '*':
					$re = $num1 * $num2;
					break;
				case '/':
					if($num2==0){
						$re='不能为0哦！';
						break;
					}
					$re = $num1 / $num2;
					break;
				default:
				
					break;
			}
		}else{
			$re='请正确输入';
		}
	}else{
		$re='请正确输入!';
	}
}
 ?>
 <!doctype html>
 <html lang="en">
 <head>
 	<meta charset="UTF-8" />
 	<title>Document</title>
 </head>
 <body>
 	<h2>结果：<span style="color: red;"><?php echo isset($re) ? $re : 0 ?></span></h2>
 	<form action="" method="post">
 		<input type="text " name="num1" id="" placeholder="0" autocomplete="off"/>
 		<br />
 		<select name="yunsuan">
 			<option value="-">-</option>
 			<option value="*">*</option>
 			<option value="/">/</option>
 			<option value="+">+</option>
 		</select>
 		<br />
 		<input type="text" name="num2" id="" placeholder="0" autocomplete="off"/><br />
 		<input type="submit" value="="/>
 	</form>
 </body>
 </html>
 